#ifndef SIO_H
#define SIO_H

#include <stdint.h>

enum sio_status_bits {
    SIO_RDRF = 0x01, // receive register full
    SIO_TDRE = 0x02, // transmit data register empty
    SIO_FE   = 0x10, // framing error
    SIO_OVRN = 0x20, // overrun error
};

enum sio_databit {
    SIO_DATABIT_7,
    SIO_DATABIT_8
};

enum sio_stopbit {
    SIO_STOPBIT_1,
    SIO_STOPBIT_2
};

enum sio_parity {
    SIO_PARITY_NONE,
    SIO_PARITY_ODD,
    SIO_PARITY_EVEN
};

enum sio_interrupt {
    SIO_INTERRUPT_DISABLE = 0x00,
    SIO_INTERRUPT_TX = 0x01,
    SIO_INTERRUPT_RX = 0x10,
};

struct sio_context {
    enum sio_databit databit;
    enum sio_stopbit stopbit;
    enum sio_parity parity;
    uint8_t interrupt;
};

struct sio_device {
    uint8_t (*status)(void);
    uint16_t (*write)(void *data, uint16_t len);
    uint16_t (*read)(void *data, uint16_t len);
};

void sio_init(struct sio_device *dev, struct sio_context *ctx);

#endif // SIO_H
